package com.shujia;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

class MyMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        //先将Text类型转成java中String类型
        String line = value.toString();
        //每一行的数据用空格进行分割
        String[] strings = line.split(" ");
        for (String word : strings) {
            context.write(new Text(word), new LongWritable(1L));
        }
//        System.out.println("数加：【"+key+"】,value:【"+value+"】");

    }
}